﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace NetDiskPRJ.BLL
{
    /// <summary>
    /// 相关系统逻辑类
    /// </summary>
    public class SysSetting
    {
        private readonly NetDiskPRJ.DAL.SysSetting SysSettingDAL = new DAL.SysSetting();

        public SysSetting()
        {
 
        }

        /// <summary>
        /// 设置数据库连接字符串
        /// <creator>wangl</creator>
        /// <user>wangl</user>
        /// <date>2013-02-17</date>
        /// </summary>
        /// <param name="sqlString"></param>
        public void SetSqlConnectionString(string sqlString)
        {
            NetDiskPRJ.DAL.SysSetting sysSettingDAL = new DAL.SysSetting();
            sysSettingDAL.SetSqlConnectionString(sqlString);
        }

        /// <summary>
        /// 获取数据库服务器系统时间
        /// <creator>wangl</creator>
        /// <date>2013-02-17</date> 
        /// </summary>
        /// <returns>null为获取失败</returns>
        public DateTime GetServerDatetime()
        {
            NetDiskPRJ.DAL.SysSetting sysSettingDAL = new DAL.SysSetting();
            return sysSettingDAL.GetServerDatetime();
        }

        /// <summary>
        /// 增加日志
        /// <creator>wangl</creator>
        /// <date>2013-02-17</date> 
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public bool AddLog(Model.Apslogrec model)
        {
            NetDiskPRJ.DAL.Apslogrec apslogrecDAL = new DAL.Apslogrec();
            return apslogrecDAL.Add(model);
        }
        /// <summary>
        /// 测试数据库连接是否成功
        /// <creator>wangl</creator>
        /// <date>2013-02-17</date>
        /// </summary>
        /// <returns>1 成功 -1 失败</returns>
        public int DBConnectTest()
        {
            NetDiskPRJ.DAL.SysSetting sysSettingDAL = new DAL.SysSetting();
            return sysSettingDAL.DBConnectTest();
        }

        /// <summary>
        /// 关闭数据库池对象
        /// <creator>wangl</creator>
        /// <date>2012-02-17</date>
        /// </summary>
        /// <param name="sqlString"></param>
        public void CloseSqlConnection()
        {
            NetDiskPRJ.DAL.SysSetting sysSettingDAL = new DAL.SysSetting();
            sysSettingDAL.CloseSqlConnection();
        }
        /// <summary>
        /// 获取在线用户数
        /// <creator>wangl</creator>
        /// <date>2013-02-17</date>
        /// </summary>
        /// <param name="appName">应用程序名</param>
        /// <returns></returns>
        public int GetOnlineCount(string appName)
        {
            NetDiskPRJ.DAL.SysSetting sysSettingDAL = new DAL.SysSetting();
            return sysSettingDAL.GetOnlineCount(appName);
        }

        /// <summary>
        /// 获取在线用户列表
        /// <creator>sunlj</creator>
        /// <date>2013-02-18</date>
        /// </summary>
        /// <param name="appName">应用程序名</param>
        /// <returns></returns>
        public DataSet GetOnlineList(string appName, string logidname)
        {
            return SysSettingDAL.GetOnlineList(appName, logidname);
        }
        /// <summary>
        /// 获取刷新后的数据(指定数据)
        /// <creator>wangl</creator>
        /// <date>2013-02-25</date>
        /// </summary>
        /// <param name="colFiledList">列的字段名集合</param>
        /// <param name="tableName">表名</param>
        /// <param name="strWhere">WHERE查询条件</param>
        /// <returns></returns>
        public DataTable GetGridRowNewData(List<string> colFiledList, string tableName, string strWhere)
        {
            return SysSettingDAL.GetGridRowNewData(colFiledList, tableName, strWhere);
        }
    }
}
